using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Dynamic;
using YTS.Tools;

namespace Test.ConsoleProgram.Algorithm.SwordFingerOffer
{
    [TestDescription("剑指 Offer 0064. 求1+2+…+n")]
    public class No0064_SumNums : AbsBaseTestItem
    {
        public override void OnTest()
        {
            Assert.TestExe(SumNums, 3, 6);
            Assert.TestExe(SumNums, 9, 45);
            Assert.TestExe(SumNums, 0, 0);
        }

        public int SumNums(int n)
        {
            bool isEnd = n > 0 && (n += SumNums(n - 1)) > 0;
            return n;
        }
    }
}
